package com.xm9m.ibczy.dsp.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.xm9m.ibczy.dsp.R;
import com.xm9m.ibczy.dsp.beans.AndoIntoBean;

/**
 * Created by baichuan on 2016/11/18.
 */

public class BannerView extends BaseView {

    private View view;
    public ImageView image;
    public TextView title, message;


    public BannerView(Context context) {
        super(context);
        initThisView(context, null, 0);
    }

    public BannerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initThisView(context, attrs, 0);
    }

    public BannerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initThisView(context, attrs, defStyleAttr);
    }

    @Override
    public void initThisView(Context context, AttributeSet attrs, int defStyleAttr) {
        view = LayoutInflater.from(context).inflate(R.layout.avia_img1, this, true);
        initView();
        initData();
        initListener();
    }

    @Override
    public void bindView() {

        AndoIntoBean.AdsBean adsBean = bean.getAds().get(0);
        if (adsBean == null)
            return;
        title.setText(adsBean.getTitle());
        message.setText(adsBean.getContent());
        String imgUrl = adsBean.getImage_urls().get(0);
        if (null == imgUrl || "".equals(imgUrl))
            return;
        setImage(image, imgUrl);

    }


    private void initView() {
        image = (ImageView) view.findViewById(R.id.advier_item_image);
        title = (TextView) view.findViewById(R.id.advier_item_title);
        message = (TextView) view.findViewById(R.id.advier_item_message);
    }

    private void initData() {

    }

    private void initListener() {

    }
}
